Page({
  data:{
    currentTab:0,
    flag:0,
    all:[],
    all2:[],
    all3:[],
    all4:[],
    all5:[],
    all6:[],
    all7:[],
    all8:[],
    showView:false,
    i:''
  },
  onLoad: function (options) {
    // 热门
    wx.request({
      url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=hot_video&size=50',
      success:res=>{
        console.log(res.data.result)
        this.setData({
          all:res.data.result
        })
      }
    })
    // 搞笑
    wx.request({
      url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=amusement_overall&size=50',
      success:res=>{
        console.log(res.data.result)
        this.setData({
          all2:res.data.result
        })
      }
    })
    // 游戏
    wx.request({
      url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=game_console&size=50',
      success:res=>{
        console.log(res.data.result)
        this.setData({
          all3:res.data.result
        })
      }
    })
        // 美食
        wx.request({
          url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=food_overall&size=50',
          success:res=>{
            console.log(res.data.result)
            this.setData({
              all4:res.data.result
            })
          }
        })
            // 汽车
    wx.request({
      url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=car_overall&size=50',
      success:res=>{
        console.log(res.data.result)
        this.setData({
          all5:res.data.result
        })
      }
    })
      // 旅游
      wx.request({
        url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=travel_overall&size=50',
        success:res=>{
          console.log(res.data.result)
          this.setData({
            all6:res.data.result
          })
        }
      })
          // 体育
    wx.request({
      url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=sport_overall&size=50',
      success:res=>{
        console.log(res.data.result)
        this.setData({
          all7:res.data.result
        })
      }
    })
        // 二次元
        wx.request({
          url: 'http://apis.juhe.cn/fapig/douyin/billboard?key=8c92536859756d26ced525fe57949f41&type=cospa_overall&size=50',
          success:res=>{
            console.log(res.data.result)
            this.setData({
              all8:res.data.result
            })
          }
        })
  },
  tiaozhuanA:function(options){
    console.log(options);
    wx.navigateTo({
      url: '../a/a?info='+encodeURIComponent(JSON.stringify(options.currentTarget.dataset.url)),
      // encodeURIComponent(JSON.stringify（））转换为json格式字符串
    })
  },

  onChangeShowState:function(e){
    console.log(e);
    var that =this;
    that.setData({
      showitem:e.currentTarget.dataset.item.video_list,
      i:e.currentTarget.dataset.index,
      show:'',
    })
    console.log(that.data.showitem);
  },

  switchNav:function(e){
    var page = this;
    var id = e.target.id;
    if(this.data.currentTab == id){
       return false;
    }else{
      page.setData({currentTab:id});
    }
    page.setData({flag:id});
  },
  onShareAppMessage: function () {
    return {
      title: '糗事百科',
      desc: '这里有搞笑的娱乐段子',
      path: '/index/index'
    }
  }
})